package com.bjsxt;
/**实体类*/
public class Person {
    private int id;
    private String name;
    //可以用int
    private String age;
    private String sex;
    //如果用long,电话号码有区号 —— 所以不可以用，
    private String telNum;//因为如果是int的类型，超出范围
    private String address;

    //因为是私有的，所以要生成get/set
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getTelNum() {
        return telNum;
    }

    public void setTelNum(String telNum) {
        this.telNum = telNum;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    //生成构造方法，当自己添加了构造方法，系统默认的无参的构造方法会
    //删除，所以要重新建无参的构造方法，因为使用时能灵活
    public Person(){}
    public Person( String name, String age, String sex, String telNum, String address) {
       //id用时是动态生成，所以这里不生成
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.telNum = telNum;
        this.address = address;
    }

    @Override
    public String toString() {
       //拼接用StringBuffer  append
        StringBuffer sb= new StringBuffer();
        sb.append("序号").append(this.id).append("#").append("\t");
        sb.append("姓名").append(this.name).append("\t\t");
        sb.append("年龄").append(this.age).append("\t\t");
        sb.append("性别").append(this.sex).append("\t\t");
        sb.append("电话号码").append(this.telNum).append("\t\t");
        sb.append("地址").append(this.address);
        return sb.toString();

    }
}
